#include<stdio.h>

#define SIZE 100000

int main() {
	int i, n, flag;
	int str[SIZE];
	while (1) {
		scanf("%d", &n);
		if (n == 0) {
			break;
		}
		for (i = 0; i < n; i++) {
			scanf("%d", &str[i]);
		}
		flag = 1;
		for (i = 0; i <= n / 2; i++) {
			if ((i + 1) != str[str[i] - 1]) {
				flag = 0;
				break;
			}
		}
		if (flag) {
			printf("\nambiguous");
		} else {
			printf("\nnot ambiguous");
		}
	}
	return 0;
}
